package com.ts.api.module.match.plan.internal.qualification.model;

import com.ts.api.module.api.entity.ApiUserRequest;
import com.ts.api.module.match.plan.model.AbstractPlanMatch;
import com.ts.api.module.product.entity.po.ProductPlanPO;
import lombok.Data;

import java.util.List;

/**
 *  计划资质通过返回实体
 *
 *  @author Pan
 */
@Data
public class PlanQualificationResult {

    /** 本次请求id */
    private String reqId;
    /** 计划匹配实体 */
    private AbstractPlanMatch abstractPlanMatch;
    /** 当前请求用户对象 */
    private ApiUserRequest apiUserRequest;
    /** 返回计划符合集合 */
    private List<ProductPlanPO> listPlanQualification;
    /** 资质验证失败对象 */
    private PlanQualificationError validateFail;

    /**
     *  构建资质校验失败
     *
     *  @param  exp          异常
     *  @return PlanQualificationResult
     */
    public static PlanQualificationResult ofFail(Exception exp) {
        PlanQualificationResult planQualificationResult = new PlanQualificationResult();

        //  创建异常
        PlanQualificationError planQualificationError = PlanQualificationError.of(exp, exp.getMessage());
        planQualificationResult.setValidateFail(planQualificationError);
        return planQualificationResult;
    }
}
